<?php include "htmlBase/header.php"; ?>

<?php
include_once 'Entidades/EntidadeBase.php';
include_once 'Entidades/Cras.php';
$servicoCras = new Cras();
$Cras = isset($_GET["Id"]) ? $servicoCras->ObterPorId($_GET["Id"]) : new Cras();
?>
<script>
    function Validar_Form(form)
    {
<?php
{
    $Cras->getJavaScriptCamposObrigatoriosInput();
}
?>
        return true;
    }
</script>

<div class="page">
    <div class="page-header">
        <div class="page-header-content">
            <h1>Cras <small>(Cadastro)</small></h1>
        </div>
        <div class="progress-bar" align="rigth">
            <div class="bar bg-color-blue" style="width: 75%"></div>
        </div>
    </div>
    <br/>
    <div class="page">
        <div class="page-region">
            <div class="page-region-content">

                <form action="CrasDados.php" method="POST" onsubmit="return Validar_Form(this);">

                    <div class="input-control" style="width: 60%; margin-left: auto; margin-right: auto;">
                        <input type="hidden" class="with-helper" name="Id" value="<?php echo $Cras->Id; ?>"/>

                        <h4>Nome</h4>
                        <input type="text" class="with-helper" placeholder="Nome" name="Nome" value="<?php echo $Cras->Nome; ?>" maxlength="60"/>

                        <h4>Endereço</h4>
                        <input type="text" class="with-helper" placeholder="Endereço" name="Endereco" value="<?php echo $Cras->Endereco; ?>" maxlength="80"/>

                        <h4>Telefone</h4>
                        <input type="text" class="with-helper" placeholder="Telefone" name="Telefone" value="<?php echo $Cras->Telefone; ?>" maxlength="30"/>

                    </div>

                    <br/>

                    <div class="input-control" style="margin-left: auto; margin-right: auto;">
                        <button class="standart default" type="submit">Salvar</button>
                        <a href="CrasCadastro.php" class="button standart">Novo</a>
                        <?php
                        if ($Cras->Id != 0)
                        {
                            ?>
                            <a href="CrasCadastro.php?Id=<?php echo $Cras->Id; ?>" class="button standart">Cancelar</a>
                            <?php
                        }
                        ?>


                        <a href="CrasPesquisa.php" class="button standart bg-color-lighten" style="float: right">Lista</a>
                    </div>

                </form>
            </div>
        </div>
    </div>

</div>

<?php include "htmlBase/footer.php"; ?>